{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "##open project"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# data is abstract Part :)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = {\n",
    "    \"accno\": [1001, 1002, 1003, 1004, 1005],\n",
    "    \"name\": [\"vaibhav\", \"abhinav\", \"aman\", \"ashish\", \"pramod\"],\n",
    "    \"balance\": [10000, 12000, 7000, 9000, 10000],\n",
    "    \"password\": [\"admin\", \"adminadmin\", \"passwd\", \"1234567\", \"amigo\"],\n",
    "    \"security_check\": [\"2211\", \"1112\", \"1009\", \"1307\", \"1103\"],\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'accno': [1001, 1002, 1003, 1004, 1005],\n",
       " 'name': ['vaibhav', 'abhinav', 'aman', 'ashish', 'pramod'],\n",
       " 'balance': [10000, 12000, 7000, 9000, 10000],\n",
       " 'password': ['admin', 'adminadmin', 'passwd', '1234567', 'amigo'],\n",
       " 'security_check': ['2211', '1112', '1009', '1307', '1103']}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                                        -------------------                                         \n",
      "                                        | Bank Application |                                        \n",
      "----------------------------------------------------------------------------------------------------\n",
      "\n",
      " 1. Login \n",
      " 2. Signup \n",
      " 3. Exit\n",
      "    enter what you want login, signup, exit :     1\n",
      "                                          login                                           \n",
      "____________________________________________________________________________________________________\n",
      "             enter account number :               1001\n",
      "                enter password :                  admin\n",
      "\n",
      " 1.check ditails \n",
      " 2. debit \n",
      " 3. credit \n",
      " 4. change password \n",
      " 5. main Manu \n",
      "              enter what you want :               1\n",
      "                                      cheak ditails                                       \n",
      "....................................................................................................\n",
      "your account number -->  1001\n",
      "your name -->  vaibhav\n",
      "your balance -->  10000\n",
      "\n",
      " 1.check ditails \n",
      " 2. debit \n",
      " 3. credit \n",
      " 4. change password \n",
      " 5. main Manu \n",
      "              enter what you want :               5\n",
      "                                        main menu                                         \n",
      "....................................................................................................\n",
      "\n",
      " 1. Login \n",
      " 2. Signup \n",
      " 3. Exit\n",
      "    enter what you want login, signup, exit :     3\n",
      "                                           exit                                           \n",
      "                                  thank you for visiting                                  \n",
      "....................................................................................................\n"
     ]
    }
   ],
   "source": [
    "# import getpass\n",
    "print(\"-------------------\".center(100))\n",
    "print(\"| Bank Application |\".center(100))\n",
    "print(\"-\" * 100)\n",
    "while True:\n",
    "    print(\"\\n 1. Login \\n 2. Signup \\n 3. Exit\")\n",
    "    i1 = int(input(\"enter what you want login, signup, exit :\".center(50)))\n",
    "    # login part\n",
    "    if i1 == 1:\n",
    "        print(\"login\".center(90))\n",
    "        print(\"_\" * 100)\n",
    "        i2 = int(input(\"enter account number : \".center(50)))\n",
    "        if i2 in (data[\"accno\"]):\n",
    "            check = (data[\"accno\"]).index(i2)\n",
    "            i3 = input(\"enter password : \".center(50))\n",
    "            check2 = data[\"password\"].index(i3)\n",
    "            if check == check2:\n",
    "                while True:\n",
    "                    print(\n",
    "                        \"\\n 1.check ditails \\n 2. debit \\n 3. credit \\n 4. change password \\n 5. main Manu \"\n",
    "                    )\n",
    "                    i4 = int(input(\"enter what you want :\".center(50)))\n",
    "                    # check ditails part\n",
    "                    if i4 == 1:\n",
    "                        print(\"cheak ditails\".center(90))\n",
    "                        print(\".\" * 100)\n",
    "                        print(f\"your account number -->  {data['accno'][check]}\")\n",
    "                        print(f\"your name -->  {data['name'][check]}\")\n",
    "                        print(f\"your balance -->  {data['balance'][check]}\")\n",
    "                        continue\n",
    "                    # debit part\n",
    "                    elif i4 == 2:\n",
    "                        print(\"debit\".center(90))\n",
    "                        print(\".\" * 100)\n",
    "                        print(f\"your balance -->  {data['balance'][check]}\")\n",
    "                        i5 = int(input(\"enter debit amount : \"))\n",
    "                        if 0 < i5 <= data[\"balance\"][check]:\n",
    "                            debit = data[\"balance\"][check] - i5\n",
    "                            data[\"balance\"][check] = debit\n",
    "                            print(\n",
    "                                f\"your remaining balance -->  {data['balance'][check]}\"\n",
    "                            )\n",
    "                        else:\n",
    "                            print(\"your debit amount is more than balance \")\n",
    "                        continue\n",
    "                    # credit part\n",
    "                    elif i4 == 3:\n",
    "                        print(\"credit\".center(90))\n",
    "                        print(\".\" * 100)\n",
    "                        print(f\"your balance -->  {data['balance'][check]}\")\n",
    "                        i6 = int(input(\"enter credit amount : \"))\n",
    "                        if 0 < i6:\n",
    "                            credit = data[\"balance\"][check] + i6\n",
    "                            data[\"balance\"][check] = credit\n",
    "                            print(f\"your new balance -->  {data['balance'][check]}\")\n",
    "                        else:\n",
    "                            print(\"your credit amount is low \")\n",
    "                        continue\n",
    "                    # password part\n",
    "                    elif i4 == 4:\n",
    "                        print(\"change password\".center(90))\n",
    "                        print(\".\" * 100)\n",
    "                        old = input(\"enter your old password : \")\n",
    "                        print(\n",
    "                            \"your password must have at list one lower case, one uppercase, one digital, one special case and length of password is 8\"\n",
    "                        )\n",
    "                        new = getpass.getpass(prompt=\"Enter your new password\")\n",
    "                        if old == data[\"password\"][check]:\n",
    "                            low, up, sp, di = 0, 0, 0, 0\n",
    "                            if (len(new)) > 8:\n",
    "                                for i in new:\n",
    "                                    if i.islower():\n",
    "                                        low += 1\n",
    "                                    if i.isupper():\n",
    "                                        up += 1\n",
    "                                    if i.isdigit():\n",
    "                                        di += 1\n",
    "                                    if i in [\"@\", \"$\", \"%\", \"^\", \"&\", \"*\"]:\n",
    "                                        sp += 1\n",
    "                            if (\n",
    "                                low >= 1\n",
    "                                and up >= 1\n",
    "                                and sp >= 1\n",
    "                                and di >= 1\n",
    "                                and low + up + sp + di == len(new)\n",
    "                            ):\n",
    "                                data[\"password\"][check] = new\n",
    "                                print(\n",
    "                                    f\"your new password -->  {data['password'][check]}\"\n",
    "                                )\n",
    "                            else:\n",
    "                                print(\"Invalid Password\")\n",
    "                        else:\n",
    "                            print(\"old password wrong please enter valid password\")\n",
    "                        continue\n",
    "                    elif i4 == 5:\n",
    "                        print(\"main menu\".center(90))\n",
    "                        print(\".\" * 100)\n",
    "                    break\n",
    "                else:\n",
    "                    print(\"please enter valid number\")\n",
    "            else:\n",
    "                print(\"please check your password number\".center(50))\n",
    "        else:\n",
    "            print(\"please check your account number\".center(50))\n",
    "    # signup part\n",
    "    elif i1 == 2:\n",
    "        print(\"signup\".center(90))\n",
    "        print(\"_\" * 100)\n",
    "        acc = 1001 + len(data[\"accno\"])\n",
    "        data[\"accno\"].append(acc)\n",
    "        ind = (data[\"accno\"]).index(acc)\n",
    "        name = input(\"enter your name : \")\n",
    "        data[\"name\"].append(name)\n",
    "        balance = int(input(\"enter your initial balance : \"))\n",
    "        data[\"balance\"].append(balance)\n",
    "        password = input(\"enter your password : \")\n",
    "        data[\"password\"].append(password)\n",
    "        security_check = (int(input(\"enter your security pin (DDMM) : \"))).split()\n",
    "        print(\".\" * 100)\n",
    "        print(f\"your account number -->  {data['accno'][ind]}\".center(50))\n",
    "        print(f\"your name -->  {data['name'][ind]}\".center(50))\n",
    "        print(f\"your balance -->  {data['balance'][ind]}\".center(50))\n",
    "        print(f\"your password --> {data['password'][ind]}\".center(50))\n",
    "        continue\n",
    "    # exit part\n",
    "    elif i1 == 3:\n",
    "        print(\"exit\".center(90))\n",
    "        print(\"thank you for visiting\".center(90))\n",
    "        print(\".\" * 100)\n",
    "        break\n",
    "    else:\n",
    "        print(f\"wrong enter : {i1}\".center(50))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# All part in function:)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "def cheak_ditails(check):\n",
    "    print(\"cheak ditails\".center(90))\n",
    "    print(\".\" * 100)\n",
    "    print(f\"your account number -->  {data['accno'][check]}\")\n",
    "    print(f\"your name -->  {data['name'][check]}\")\n",
    "    print(f\"your balance -->  {data['balance'][check]}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "def credit(check):\n",
    "    print(\"credit\".center(90))\n",
    "    print(\".\" * 100)\n",
    "    print(f\"your balance -->  {data['balance'][check]}\")\n",
    "    i6 = int(input(\"enter credit amount : \"))\n",
    "    if 0 < i6:\n",
    "        credit = data[\"balance\"][check] + i6\n",
    "        data[\"balance\"][check] = credit\n",
    "        print(f\"your new balance -->  {data['balance'][check]}\")\n",
    "    else:\n",
    "        print(\"your credit amount is low \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "def debit(check):\n",
    "    print(\"debit\".center(90))\n",
    "    print(\".\" * 100)\n",
    "    print(f\"your balance -->  {data['balance'][check]}\")\n",
    "    i5 = int(input(\"enter debit amount : \"))\n",
    "    if 0 < i5 <= data[\"balance\"][check]:\n",
    "        debit = data[\"balance\"][check] - i5\n",
    "        data[\"balance\"][check] = debit\n",
    "        print(f\"your remaining balance -->  {data['balance'][check]}\")\n",
    "    else:\n",
    "        print(\"your debit amount is more than balance \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "def change_password(check):\n",
    "    print(\"change password\".center(90))\n",
    "    print(\".\" * 100)\n",
    "    old = input(\"enter your old password : \")\n",
    "    print(\n",
    "        \"your password must have at list one lower case, one uppercase, one digital, one special case and length of password is 8\"\n",
    "    )\n",
    "    new = getpass.getpass(prompt=\"Enter your new password\")\n",
    "    if old == data[\"password\"][check]:\n",
    "        low, up, sp, di = 0, 0, 0, 0\n",
    "        if (len(new)) > 8:\n",
    "            for i in new:\n",
    "                if i.islower():\n",
    "                    low += 1\n",
    "                if i.isupper():\n",
    "                    up += 1\n",
    "                if i.isdigit():\n",
    "                    di += 1\n",
    "                if i in [\"@\", \"$\", \"%\", \"^\", \"&\", \"*\"]:\n",
    "                    sp += 1\n",
    "        if (\n",
    "            low >= 1\n",
    "            and up >= 1\n",
    "            and sp >= 1\n",
    "            and di >= 1\n",
    "            and low + up + sp + di == len(new)\n",
    "        ):\n",
    "            data[\"password\"][check] = new\n",
    "            print(f\"your new password -->  {data['password'][check]}\")\n",
    "        else:\n",
    "            print(\"Invalid Password\")\n",
    "    else:\n",
    "        print(\"old password wrong please enter valid password\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "def login():\n",
    "    print(\"login\".center(90))\n",
    "    print(\"_\" * 100)\n",
    "    i2 = int(input(\"enter account number : \".center(50)))\n",
    "    if i2 in (data[\"accno\"]):\n",
    "        check = (data[\"accno\"]).index(i2)\n",
    "        i3 = input(\"enter password : \".center(50))\n",
    "        check2 = data[\"password\"].index(i3)\n",
    "        if check == check2:\n",
    "            while True:\n",
    "                print(\n",
    "                    \"\\n 1.check ditails \\n 2. debit \\n 3. credit \\n 4. change password \\n 5. main Manu \"\n",
    "                )\n",
    "                i4 = int(input(\"enter what you want :\".center(50)))\n",
    "                # check ditails part\n",
    "                if i4 == 1:\n",
    "                    cheak_ditails(check)\n",
    "                    continue\n",
    "                # debit part\n",
    "                elif i4 == 2:\n",
    "                    debit(check)\n",
    "                    continue\n",
    "                # credit part\n",
    "                elif i4 == 3:\n",
    "                    credit(check)\n",
    "                    continue\n",
    "                # password part\n",
    "                elif i4 == 4:\n",
    "                    change_password(check)\n",
    "                    continue\n",
    "                elif i4 == 5:\n",
    "                    print(\"main menu\".center(90))\n",
    "                    print(\".\" * 100)\n",
    "                break\n",
    "            else:\n",
    "                print(\"please enter valid number\")\n",
    "        else:\n",
    "            print(\"please check your password number\".center(50))\n",
    "    else:\n",
    "        print(\"please check your account number\".center(50))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [],
   "source": [
    "def security_check(ss):\n",
    "    data = {(1, 3, 5, 7, 8, 10, 12): 31, (2,): 29, (4, 6, 9): 30}\n",
    "    month = ss[2:]\n",
    "    date = ss[:2]\n",
    "    for key, value in data.items():\n",
    "        print(key, value)\n",
    "        if int(month) in key:\n",
    "            if 1 <= int(date) <= value:\n",
    "                return True\n",
    "            return False\n",
    "    return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [],
   "source": [
    "def signup():\n",
    "    print(\"signup\".center(90))\n",
    "    print(\"_\" * 100)\n",
    "    acc = 1001 + len(data[\"accno\"])\n",
    "    data[\"accno\"].append(acc)\n",
    "    ind = (data[\"accno\"]).index(acc)\n",
    "    name = input(\"enter your name : \")\n",
    "    data[\"name\"].append(name)\n",
    "    balance = int(input(\"enter your initial balance : \"))\n",
    "    data[\"balance\"].append(balance)\n",
    "    password = input(\"enter your password : \")\n",
    "    data[\"password\"].append(password)\n",
    "    ss = input(\"enter a secuirty quetion in form dd//mm\")\n",
    "    security_check(ss)\n",
    "    data[\"security_check\"].append(ss)\n",
    "    print(\".\" * 100)\n",
    "    print(f\"your account number -->  {data['accno'][ind]}\".center(50))\n",
    "    print(f\"your name -->  {data['name'][ind]}\".center(50))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                                        -------------------                                         \n",
      "                                        | Bank Application |                                        \n",
      "----------------------------------------------------------------------------------------------------\n",
      "\n",
      " 1. Login \n",
      " 2. Signup \n",
      " 3. Exit\n",
      "    enter what you want login, signup, exit :     2\n",
      "                                          signup                                          \n",
      "____________________________________________________________________________________________________\n",
      "enter your name : am\n",
      "enter your initial balance : 1000\n",
      "enter your password : amn11\n",
      "enter a secuirty quetion in form dd//mm1103\n",
      "(1, 3, 5, 7, 8, 10, 12) 31\n",
      "....................................................................................................\n",
      "          your account number -->  1013           \n",
      "                your name -->  am                 \n",
      "\n",
      " 1. Login \n",
      " 2. Signup \n",
      " 3. Exit\n"
     ]
    }
   ],
   "source": [
    "def main():\n",
    "    print(\"-------------------\".center(100))\n",
    "    print(\"| Bank Application |\".center(100))\n",
    "    print(\"-\" * 100)\n",
    "    while True:\n",
    "        print(\"\\n 1. Login \\n 2. Signup \\n 3. Exit\")\n",
    "        i1 = int(input(\"enter what you want login, signup, exit :\".center(50)))\n",
    "        # login part\n",
    "        if i1 == 1:\n",
    "            login()\n",
    "        # signup part\n",
    "        elif i1 == 2:\n",
    "            signup()\n",
    "        # exit part\n",
    "        elif i1 == 3:\n",
    "            print(\"exit\".center(90))\n",
    "            print(\"thank you for visiting\".center(90))\n",
    "            print(\".\" * 100)\n",
    "            break\n",
    "        else:\n",
    "            print(f\"wrong enter : {i1}\".center(50))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
